import React from 'react';
import {Badge} from 'antd';
import Constants from "../utils/Constants";
import Utils from "../utils";

module.exports = [

  {
    key: 'id',
    title: '分类ID',
    dataType: 'int',
    primary: true,
    showType: 'normal',
    showInTable: true,
    showInForm: true,
    disabled: true,
    render: (text, record) => text
  },
  {
    key: 'name',
    title: '分类名称',
    dataType: 'varchar',
    validator: [{required: true, message: '此项必填'}],
  },
  {
    key: 'pid',
    title: '上级分类',
    dataType: 'int',
    showType: 'select',
    showInTable: false,
    optionFormat: "id:name",
    isAsyncData: true,
    url: 'goodsCategory/select2',
    validator: [{required: true, message: '此项必填'}],
  },
  {
    key: 'status',
    title: '状态',
    dataType: 'int',
    showType: 'select',
    options: Utils.map2kvArr(Constants.GOODS_CATEGORY_MAP),
    defaultValue: 0,
    render: (record) => <Badge status={record === '启用' ? 'success' : 'error'} text={record}/>,
  },
  {
    key: 'createTime',
    title: '创建时间',
    dataType: 'varchar',
    showInForm: false
  },
  {
    key: 'updateTime',
    title: '修改时间',
    dataType: 'varchar',
    showInForm: false
  }
];